<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">

    <script type="text/javascript" src="js/jquery-3.6.0.js"></script>
    <script type="text/javascript" src="js/jquery.cookie.js"></script>
    <script type="text/javascript" src="js/constants.js"></script>
    <script type="text/javascript" src="js/user-manager.js"></script>
    <script type="text/javascript" src="js/des.js"></script>

    <style>
        .lock {
            display: flex;
            align-items: center;
            flex-direction: row;
            justify-content: center;
        }

        .login {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 450px;
            height: 396px;
            background-color: white;
        }

        .input {
            font-size: 18px;
            height: 65px;
            width: 390px;
            border: 0px;
            outline: none;
            text-align: center;
            border-bottom: 1px solid #D9D9D9;
        }

        .button {
            font-size: 19px;
            height: 55px;
            width: 390px;
            border: 0px;
            outline: none;
            text-align: center;
            margin-top: 40px;
            background-color: #1A7DFF;
            color: #FFFFFF;
            border-radius: 8px;
        }
    </style>

    <script type="text/javascript" src="js/jquery-3.6.0.js"></script>
    <script type="text/javascript" src="js/jquery.cookie.js"></script>
    <script type="text/javascript">
        //防止页面后退
        history.pushState(null, null, document.URL);
        window.addEventListener('popstate', function () {
            history.pushState(null, null, document.URL);
        });

        var isShowLogin = false;

        function onLogin() {
            if (!isShowLogin) {
                $("#lock").hide();
                $("#login").show();
                isShowLogin = true;
                $("#account").val($.cookie('truename'));
            }
        }

        function onClose() {
            console.log("isShowLogin: ", isShowLogin);
            if (isShowLogin) {
                $("#lock").show();
                $("#login").hide();
                isShowLogin = false;
            }
        }

        function onUnlock() {
            var password = $("#password").val();
            if (password === $.cookie("password")) {
                $.ajax({
                    type: "POST",
                    url: serverApi + "/sysdoctor/updateLastTime?doctorId=" + $.cookie("doctorId"),
                    success: function (result) {
                        if (result.code === 200) {
                            $.cookie('unlock', 1, {path: '/'});
                            console.log("解锁成功")
                            parent.layer.closeAll();
                        }
                    }
                });
            }
        }
    </script>
</head>
<body style="margin: 0 0 0 0;">
<div id="lock" class="lock">
    <img src="img/home/ic_lock.png" style="width: 300px;height: 300px;cursor: pointer;" onclick="onLogin()"/>
</div>
<div id="login" class="login" style="display: none;">
    <img src="img/home/lock_login.png" style="width: 104px;height: 99px;margin-top: 30px;"/>
    <img src="img/dialog_close.png"
         style="width: 29px;height: 29px;position: absolute;top: 20px;right: 20px;cursor: pointer;"
         onclick="onClose()"/>
    <input id="account" type="text" disabled="true" class="input" style="color: #1A7DFF;margin-top: 20px;"/>
    <input id="password" type="password" class="input" placeholder="请输入登录密码" style="color: #999999;"/>
    <input type="button" class="button" value="解锁" onclick="onUnlock()"/>
</div>
</body>
</html>
